package com.example.springtransdemo.controller;

import com.example.springtransdemo.service.LogService;
import com.example.springtransdemo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("trans2")
public class LogController {

    @Autowired
    private UserService userService;
    @Autowired
    private LogService logService;
    @Transactional
    @RequestMapping("/registry")
    public Boolean registry(String userName,String password){
        Integer result = userService.insertInfo(userName,password);
        log.info("表一影响的行数:"+result);
        Integer result1 = logService.insertInfo(userName,"registry");
        log.info("表二影响的行数:"+result1);
        return true;
    }

}
